﻿package  
{
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	
	/**
	 * ...
	 * @author Daniel Sheldon
	 */
	public class Hill extends Sprite
	{		
		static public var maxAnts:int = 1500;
		static public var density:int = 15;
		
		private var startX:Number;
		private var startY:Number;
		private var target:DisplayObjectContainer;
		private var _createdAnts:int = 0;
		
		/*	
		private var _myR:uint = Math.random()*0xff;
		private var _myB:uint = Math.random()*0xff;
		private var _myG:uint = Math.random()*0xff;
		
		
		private var _myR:uint = 0xff
		private var _myB:uint = 0xff
		private var _myG:uint = 0xff;
		*/
		public function Hill(startX:Number, startY:Number, target:DisplayObjectContainer) 
		{
			this.startX = startX;
			this.startY = startY;
			this.target = target;
			
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event):void 
		{
			
			addEventListener(Event.ENTER_FRAME, addAnts);
		}
		
		private function addAnts(e:Event):void 
		{
			for (var i:int = 0; i < density; i++)
			{
				var ant:Ant = new Ant(createdAnts);
				ant.home = this;
				
				ant.x = startX + Math.random()*Ant.speed-Ant.speed/2;
				ant.y = startY + Math.random()*Ant.speed-Ant.speed/2;
				
				target.addChild(ant);
				_createdAnts++;
				
				if (createdAnts >= maxAnts)
				{
					removeEventListener(Event.ENTER_FRAME, addAnts);
				}
			}
		}
		
		/*public function get myR():uint { return _myR; }
		
		public function get myB():uint { return _myB; }
		
		public function get myG():uint { return _myG; }*/
		
		public function get createdAnts():int { return _createdAnts; }
		
	}
	
}